package com.wzy.sort8;

import java.util.Arrays;

/**
 * @author wzy
 * @Date: 2022/1/30 13:23
 * @Description: 冒泡排序
 */
public class MaoPao {
    public static void main(String[] args) {
        int[] nums = {5, 1, 8, 2, 6, 7, 3, 4};
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] > nums[j]){
                    swap(nums,i,j);
                }
            }
        }
        System.out.println(Arrays.toString(nums));
    }
    public static void swap(int[] nums,int i,int j){
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }
}
